package com.cams.backend.controller;


import com.cams.backend.common.lang.Result;
import com.cams.backend.entity.Work;
import com.cams.backend.service.WorkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cams
 * @since 2022-05-15
 */
@RestController
@RequestMapping("/work")
public class WorkController {

    @Autowired
    WorkService workService;

    /**
     * 发起排班
     * 交互接口
     * @author chs
     */
    @PostMapping("/schedule")
    public Result workSchedule(@RequestBody Work work){
        return workService.workShedule(work);
    }

    /**
     * 查看所有排班信息(无条件查询)
     * 交互接口
     * @author chs
     */
    @GetMapping("/check/all")
    public Result workCheckAll(){
        return workService.workCheckAll();
    }

    /**
     * 查看某员工排班信息(根据uid查询)
     * 交互接口
     * @author chs
     */
    @GetMapping("/check/{uid}")
    public Result leaveCheckByUid(@PathVariable("uid") int uid){
        return workService.workCheckByUid(uid);
    }



    /**
     * 排班信息删除
     * 交互接口
     * @author chs
     */
    @DeleteMapping  ("/delete/{wid}")
    @ResponseBody
    public Result deleteWorkByWid(@PathVariable("wid") int wid){
        return workService.deleteWorkByWid(wid);
    }

    /**
     * 修改排班信息
     * 交互接口
     * @author chs
     */
    @PostMapping("/update")
    public Result updateWorkInfo(@RequestBody Work work){
        return workService.updateWorkInfo(work);

    }

}
